from django.shortcuts import render
from django.forms import model_to_dict
from rest_framework import views
from rest_framework.response import Response
from rest_framework import generics, viewsets
from rest_framework.decorators import action

from . import models
from . import serializers
from . import permissions


class NewsAPIAll(generics.ListCreateAPIView):
    queryset = models.News.objects.all()
    serializer_class = serializers.NewsSerializer


class NewsAPIDestroy(generics.RetrieveDestroyAPIView):
    queryset = models.News.objects.all()
    serializer_class = serializers.NewsSerializer


class NewAPIUpdate(generics.RetrieveUpdateAPIView):
    queryset = models.News.objects.all()
    serializer_class = serializers.NewsSerializer
    permission_classes = (permissions.IsOwnerOrReadOnly, )
